package com.loong.android.tools;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.telephony.TelephonyManager;

public class Phone {
    //硬件制造商
    public final static String MANUFACTURER = Build.MANUFACTURER;
    //硬件标识码
    public final static String FINGERPRINT = Build.FINGERPRINT;
    //型号
    public final static String MODEL = Build.MODEL;
    //主板信息
    public final static String BOARD = Build.BOARD;
    //系统定制商
    public final static String BRAND = Build.BRAND;
    //产品名称
    public final static String PRODUCT = Build.PRODUCT;
    //设备信息
    public final static String DEVICE = Build.DEVICE;
    //屏幕信息
    public final static String DISPLAY = Build.DISPLAY;
    //CPU指令集
    public final static String CPU_ABI = Build.CPU_ABI;
    //CPU指令集2
    public final static String CPU_ABI2 = Build.CPU_ABI2;
    //SDK版本
    public final static int SDK_INT = Build.VERSION.SDK_INT;

    /**
     * 跳转到拨号界面
     *
     * @param context 上下文
     * @param tel     电话号码
     */
    public static void openDialWin(Context context, String tel) {
        context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + tel)));
    }

    /**
     * 判断是否为真机
     *
     * @param context 上下文
     * @return true=真机; false=非真机
     */
    public static boolean isRealPhone(Context context) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return (tm != null ? tm.getPhoneType() : -1) != TelephonyManager.PHONE_TYPE_NONE;
    }

    /**
     * 获取sim卡的状态
     *
     * @param context 上下文
     * @return -1=获取失败; 0=未知状态; 1=无SIM卡; 2=需要PIN解锁; 3=需要PUK解锁;
     * 4=需要Network PIN解锁; 5=就绪; 6=未就绪; 7=损坏; 8=存在故障; 9=用户禁用。
     */
    public static int getSimState(Context context) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return tm == null ? -1 : tm.getSimState();
    }
}
